//
//  SettingViewController.m
//  Mall
//
//  Created by Bear on 16/10/17.
//  Copyright © 2016年 孙飞燕. All rights reserved.
//

#import "SettingViewController.h"
@interface SettingViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong)UITableView *tableView;
@property (nonatomic,strong)NSMutableArray *dataSourceArr;
@end

@implementation SettingViewController
- (NSMutableArray *)dataSourceArr{
    if (!_dataSourceArr) {
        _dataSourceArr = [[NSMutableArray alloc]initWithObjects:@"个人资料",@"账户与安全",@"消息提醒设置",@"仅Wi-Fi下显示图片",@"邀请好友使用",@"关于商城",@"检查更新",@"清除缓存", nil];
    }
    return _dataSourceArr;
}
- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStyleGrouped];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
        _tableView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    }
    return _tableView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.tableView];
    // Do any additional setup after loading the view.
}

#pragma mark ------UITableView的代理方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 6;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0 || section == 1 || section == 3 || section == 5) {
        return 1;
    }else{
        return 2;
    }
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    if (indexPath.section == 0) {
        cell.textLabel.text = @"个人资料";
    }else if (indexPath.section == 1){
        cell.textLabel.text = @"账户与安全";

    }else if (indexPath.section == 2){
        if (indexPath.row == 0) {
            cell.textLabel.text = @"消息提醒设置";
        }else{
            cell.textLabel.text = @"仅Wi-Fi下显示图片";
        }
    }else if (indexPath.section == 3){
        cell.textLabel.text = @"邀请好友使用";
    }else if (indexPath.section == 4){
        if (indexPath.row == 0) {
            cell.textLabel.text = @"关于商城";
        }else{
            cell.textLabel.text = @"检查更新";
        }
    }else{
        cell.textLabel.text = @"清除缓存";
        cell.textLabel.textColor = [UIColor redColor];
    }
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        PersonalDataViewController *dataVC = [[PersonalDataViewController alloc]init];
        [self.navigationController pushViewController:dataVC animated:YES];
    }else if (indexPath.section == 1){
        AccountSecurityViewController *accountVC = [[AccountSecurityViewController alloc]init];
        [self.navigationController pushViewController:accountVC animated:YES];
    }
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
